﻿using System.Web;
using System.Web.Routing;
using Isis.Handlers;

namespace Isis
{
    public class IsisRoutingModule : IHttpModule
    {
        private static bool _hasRun;

        public void Dispose()
        {
        }

        public void Init(HttpApplication context)
        {
            if (_hasRun) return;

            RegisterRoutes(RouteTable.Routes);
            _hasRun = true;
        }

        public static void RegisterRoutes(RouteCollection routes)
        {
            var isisHandler = new IsisRoutingHandler();
            routes.Add(new Route("isis", isisHandler));
            routes.Add(new Route("isis/{controller}", isisHandler));
            routes.Add(new Route("isis/{controller}/{action}", isisHandler));
            routes.Add(new Route("isis/{controller}/{action}/{parameter}", isisHandler));
        }
    }
}